package com.aaa.java14;

import java.util.Collections;
import java.util.HashSet;
import java.util.Random;
import java.util.TreeSet;

/**
 * @author ：Teacher陈（86521760@qq.com）
 * @date ：Created in 2022/7/18 9:31
 * @description：
 * @modified By：
 * @version:
 */
public class TreeSetTest {
    public static void main(String[] args) {
      /*  //使用hashset封装数据
        HashSet<Integer> hashSet = new HashSet();
        hashSet.add(30);
        hashSet.add(20);
        hashSet.add(50);
        hashSet.add(19);
        System.out.println(hashSet);
        //使用treeset封装数据
        TreeSet<Integer> treeSet = new TreeSet();
        treeSet.add(30);
        treeSet.add(20);
        treeSet.add(50);
        treeSet.add(19);
        System.out.println(treeSet);*/
        //放入teacher对象到hashSet里面，查看结果，是否自动排序
        HashSet<Teacher> hashSet= new HashSet<>();
        Teacher teacher1 = new Teacher();
        teacher1.setId(1000);
        teacher1.setName("老师1");
        //设置工资
        teacher1.setSal(10000);
        //实例化对象之后，及时存入list集合中
        hashSet.add(teacher1);
        Teacher teacher2 = new Teacher();
        teacher2.setId(1000);
        teacher2.setName("老师1");
        //设置工资
        teacher2.setSal(10000);
        //实例化对象之后，及时存入list集合中
        hashSet.add(teacher2);
        System.out.println("结果：");
        for (Teacher teacher : hashSet) {
            System.out.println(teacher);
        }

        //放入teacher对象到treeSet里面，查看结果，是否自动排序
       /*TreeSet<Teacher> teacherTreeSet= new TreeSet<>();
        Teacher teacher1 = new Teacher();
        teacher1.setId(1000);
        teacher1.setName("老师1");
        //设置工资
        teacher1.setSal(10000);
        //实例化对象之后，及时存入list集合中
        teacherTreeSet.add(teacher1);
        Teacher teacher2 = new Teacher();
        teacher2.setId(1000);
        teacher2.setName("老师1");
        //设置工资
        teacher2.setSal(10000);
        //实例化对象之后，及时存入list集合中
        teacherTreeSet.add(teacher2);
        System.out.println("结果：");
        for (Teacher teacher : teacherTreeSet) {
            System.out.println(teacher);
        }*/

    }
}
